package com.xzcedu.regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 徐州城
 * @version 1.0
 * 演示字符匹配符的使用
 */
public class RegExp03 {
    public static void main(String[] args) {

        String content = "aq11_c8abcABCxD￥";
        //String regStr = "[a-z]"; //匹配a-z之间的任意一个字符
        //String regStr = "[A-Z]"; //匹配a-z之间的任意一个字符
        //String regStr = "abc"; //匹配 abc 字符[默认区分大小写]
        //String regStr = "(?i)abc"; //匹配 abc 字符[不区分大小写]
        //String regStr = "[abcd]"; //匹配 abcd 任意一个字符
        //String regStr = "\\D"; //匹配 不在0-9 任意一个字符
        String regStr = "\\w"; //匹配任意英文字符、数字和下划线

        //说明
        //1. 当创建Pattern对象时，指定 Pattern.CASE_INSENSITIVE，表示匹配是不区分大小写
        Pattern pattern = Pattern.compile(regStr/*, Pattern.CASE_INSENSITIVE*/);
        Matcher matcher = pattern.matcher(content);

        while (matcher.find()) {
            System.out.println("找到: " + matcher.group(0));
        }
    }
}
